package com.chris.controller;

import com.chris.thrift.message.MessageService;
import org.apache.thrift.protocol.TBinaryProtocol;
import org.apache.thrift.transport.TFramedTransport;
import org.apache.thrift.transport.TSocket;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class TestController {

    @GetMapping("sendEmail")
    public String sendEmail() throws Exception {
        TSocket tSocket = new TSocket("127.0.0.1",9090, 10000 );
        TFramedTransport tFramedTransport = new TFramedTransport(tSocket);
        tFramedTransport.open();
        TBinaryProtocol tBinaryProtocol = new TBinaryProtocol(tFramedTransport);
        MessageService.Client client = new MessageService.Client(tBinaryProtocol);
        boolean result = client.sendEmailMessage("smilechris@yeah.net", "testdsfdsfdsfsdfdsfdfsdfdsfdsafvrbsagf code:8787 email");
        return String.valueOf(result);
    }


}
